<% total = @search_results && @search_results.info[:total]
   title = "Search Results"
   if total
     if total > @search_results.size
       title += " #{"<small class='text-error'>(restricting to #{@search_results.size} matches out of #{total})</small>"}"
     else
       title += " #{"<small class='text-success'>(#{pluralize(@search_results.size, 'match')})</small>"}"
     end
   end %>
<%= section_panel raw(title), :width => 'double', :position => 'right' do %>
  <% if @error.present? %>
    <p>
      Failed to evaluate query.  Make sure query definition is valid.
      <br/>
      <div><code><%= @error %></code></div>
    </p>
  <% elsif @search_results.blank? %>
    No matches found
  <% else %>
    <%= ci_list(@search_results,
                :toolbar => {:sort_by   => [%w(Name ciName), %w(Class ciClassName), %w(Namespace nsPath)],
                             :filter_by => %w(ciName ciClassName nsPath),
                             :compact   => false}) do |builder, ci| %>
      <% builder.attributes %(ciName="#{ci.ciName}" ciClassName="#{ci.ciClassName}" nsPath="#{ci.nsPath}") %>
      <% attr_name = params[:attr_name] %>
      <% builder.top do %>
        <span class="topname"><%= link_to(ci.ciName, path_to_ci!(ci)) %></span>
      <% end %>
      <% builder.middle do %>
        <% if attr_name.present? %>
          <dl class="dl-horizontal">
            <% a = ci.meta.md_attribute(attr_name)
               desc = a ? a.description : attr_name %>
            <dt title="<%= desc %>"><%= desc %></dt>
            <dd><%= ci.ciAttributes.attributes[attr_name] %></dd>
          </dl>
        <% else %>
          <%= render 'cms/cis/important', :ci => ci %>
        <% end %>
      <% end %>
      <% builder.bottom link_to(ci.nsPath, path_to_ns(ci.nsPath)) %>
      <% builder.status :none %>
    <% end %>
  <% end %>
<% end %>

